import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  define: {
    __ACCEPT_IMG_TYPE__: ['jpg', 'jpeg', 'png', 'svg', 'gif'],
    __API_BASE_URL__: JSON.stringify('/api'),
    __API_OSS_URL__: JSON.stringify('https://shuzhi-static.tourage.cn/default')
},
  plugins: [react()],
  resolve: {
    // 添加路径别名
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  server: {
    port: 8000,
    proxy: {
      "/api": {
        // target: "https://jintan.tourage.cn/api",
        target: "https://hunan.tourage.cn/api",
        // target: 'https://guangxi.tourage.cn/api',
        // target: 'https://jiaxian.tourage.cn/api',
        // ws: true, //如果要代理 websockets，配置这个参数
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});
